package com.example.senior_config.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

/**
 * @author ljw
 * @description
 * @date 2021/9/10 8:06
 */
@RestController
public class SeeController {
    
    /**
     * 媒体类型是 text/event-stream 是服务器端的SSE 的支持
     * @param 
     * @author ljw
     * @date 2021/9/10 8:14
     */
    @RequestMapping(value = "/push", produces = "text/event-stream")
    public String push() {
        Random random = new Random();
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "data:Testing 1,2,3 "+random.nextInt()+"\n\n";
    }
}
